/*
 * User: user
 * Date: 30/12/2007
 * Time: 00:49:45
 */
package org.conann.instrument.md;

import com.google.common.collect.Sets;
import javassist.*;
import org.conann.instrument.CtUtil;
import org.conann.metadata.BeanMD;
import org.conann.util.DevelopmentUtil;

import java.util.Set;

/** Compile-time TypeRecord */
public class CtClassRecord {

    private final CtClass ctClass;
    private final BeanMD beanMD;
    private final Set<CtClass> interfaces;
    private final Set<CtField> fields;
    private final CtConstructor constructor;
    private final CtMethod initalizerMethod;
    private final CtMethod removeMethod;
    private static final CtClass[] EMPTY_CLASS_ARRAY = new CtClass[0];

    public CtClassRecord(CtClass ctClass) {
        this.ctClass = ctClass;
        beanMD = CtUtil.getComponentMD(ctClass);
        interfaces = Sets.newHashSet(resolveInterfaces());
        fields = Sets.newHashSet(ctClass.getDeclaredFields());
        constructor = resolveContructor();
        initalizerMethod = resolveInitializerMethod();
        removeMethod = resolveRemoveMethod();
    }

    private CtClass[] resolveInterfaces() {
        CtClass[] classes = EMPTY_CLASS_ARRAY;
        try {
            classes = ctClass.getInterfaces();
        } catch (NotFoundException e) {
            // TODO ophir >> what should be done here? is this ok?
        }
        return classes;
    }

    private CtConstructor resolveContructor() {
        throw DevelopmentUtil.unsupportedOperation();
    }

    private CtMethod resolveInitializerMethod() {
        throw DevelopmentUtil.unsupportedOperation();
    }

    private CtMethod resolveRemoveMethod() {
        throw DevelopmentUtil.unsupportedOperation();
    }
}